<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的电子码</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="{{ url('/common/mobile-common/common.css') }}">
<link rel="stylesheet" href="{{ url('/mobile/css/header.css') }}">		
<link rel="stylesheet" href="{{ url('/mobile/css/card/cardDzm.css') }}">	
<script src="{{ url('mobile/js/jquery-1.8.3.min.js') }}"></script>
<link rel="stylesheet" href="{{ url('/') }}/layer/skin/layer.css" />
<script src="{{ url('/') }}/layer/layer.js"></script>
<script src="{{ url('/common/mobile-common/hmt.js') }}"></script>
</head>
<body>
	<div class="abouts">
		<div class="wrap-cont clearfix">
				<div class="wrap-cont wrap-cont2">
					<div class="km">
						<label>账号:</label>
						<p><input type="text" name="cardNum" class="zh-num" placeholder="请输入账号"></p>
						<label>密码:</label>
						<p>
							<input type="password" name="password" class="mm-num" placeholder="请输入密码">
							<!-- <input type="file" style="visibility: hidden;" class="in-sc"> -->
							<button class="btn-sc">生成</button>
						</p>
					</div>
				</div>
				<!--点击上传头像-->
				@foreach($res as $v)
				<div class="wrap-cont wrap-cont3">
					<div class="dzmDv2 clearfix">
						<label>账号:</label>
						<p>{{$v->card_num}}</p>
						<label>密码:</label>
						<p>{{$v->password}}</p>
						<label>有效期:</label>
						<p>{{App\Http\Util\TimeHelper::formatDate($v->start_time)}} 至 {{App\Http\Util\TimeHelper::formatDate($v->end_time)}}</p>						
						<a href="javascript:void(0)" class="djsc" data-id="{{$v->id}}">
							<i>+</i><span>点击上传头像并生成电子卡</span>
						</a>
						<form id="form" class="form" action="{{url('wap/card/uploadImg')}}" method="post" enctype="multipart/form-data">
							<input type="hidden" name="cardId" value="{{$v->id}}">
							<input type="file" name="head" class="head"  accept="image/*" style="visibility: hidden;display: block">
						</form>
					</div>
				</div>
				@endforeach
		</div>
	</div>
	
</body>
<script>
	$(function(){
		if ("{{session('status')}}"==1) {
			alert("上传成功,请到电子旅游卡处查看！");
		}
		if ("{{session('status2')}}"==2) {
			alert("此码已被他人激活！");
		}
		//点击生成,验证账号密码 上传头像
		$(".djsc").unbind().click(function() {
			$(this).parent().find('.head').click();
		});
			});
		$(".head").click(function(){
			$('.head').change(function() {
				$(this).parent().submit();
			})
		});
		$(".btn-sc").click(function(){
			var zhNum=$(".zh-num").val();
			var maNum=$(".mm-num").val();
			if(zhNum==''||zhNum=='请输入账号'){
				alert("请输入账号");
				$(".zh-num").focus();
				return false;
			}
			else if(maNum==''||maNum=='请输入密码'){
				alert('请输入密码');
				$(".mm-num").focus();
				$(".mm-num").val(maNum);
				return false;
			}
			var cardNum = $("[name=cardNum]").val();
			var password = $("[name=password]").val();
			$.ajax({
				url: "{{ url('wap/card/dzm') }}",
				type: "post",
				dataType: "json",
				data: {cardNum: cardNum,password:password},
				success: function (data) {
					if (data.success) {
						layer.alert(data.msg,function(){
							layer.closeAll();
							window.location.href="{{url('wap/card/dzm?id=1')}}";
						});
					}
					else {
						layer.alert(data.msg);
					}
				}
			});

			$(".dzmDv2 p").css("color","#666666!important");
	});

</script>
</html>
